package main

import (
	"fmt"
	"gitee.com/DengAnbang/goutils/update"
	"net/http"
	"os"
	"path/filepath"
	"time"
)

func main() {

	mux := http.NewServeMux()
	mux.HandleFunc("/", handler)
	mux.HandleFunc("/test", test)
	update.UpgradeService(":8081", mux)
}
func handler(w http.ResponseWriter, r *http.Request) {
	err := filepath.Walk("./update/test", func(path string, f os.FileInfo, err error) error {
		if f == nil {
			return err
		}
		if f.IsDir() {
			fmt.Fprintln(w, f.Name())
			return nil
		}
		return nil
	})
	if err != nil {
		panic(err)
	}
}
func test(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()
	time.Sleep(time.Second * time.Duration(5))
	fmt.Fprintf(w, "时间 =%d", os.Getpid())
}
